package objetosGraficos;

import java.awt.Point;
import java.util.Random;

import javax.swing.ImageIcon;

import logica.Reproductor;
/**
 * Clase que representa el jefe final del nivel
 * @author Christian
 *
 */
public class BOSS extends NaveEnemiga{

	//Atributos
	private Point movimiento = new Point(1,0);
	private Random r = new Random();
	
	public BOSS() {
		super(12, SpriteStore.get().getImage("BOSS"), SpriteStore.get().getImage("BOSS").getIconWidth(), 
				SpriteStore.get().getImage("BOSS").getIconHeight(), "BOSS", 1500, 2000, 100);
		
	}
	
	/**
	 * Mueve la nave.
	 */
	public void mover (){
		if (this.getX() > -this.getWidth()-1 && this.getX() < (551+this.getWidth())){
			this.setLocation((int) (this.getX() + (movimiento.getX() * this.getFactor())),this.getY());
		} else {
			int random = r.nextInt(2);
			if (random == 0){
				movimiento = new Point(1,0);
				this.setLocation(-this.getWidth(),0);
			}else{
				movimiento = new Point(-1,0);
				this.setLocation(550+this.getWidth(),0);
			}
		}
	}
	
	/**
	 * La nave muere y deja de estar activa.
	 */
	public void morir (){
		for ( int i = 0; i < 6; i ++){
			Reproductor r = new Reproductor ();
			r.cargarAudio("explosion.mp3");
			r.reproducirdetener();
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}	
		}
		super.morir();
		
	}

}
